# --*-- coding:utf8 --*--
import os
from pyecharts import options as opts
from pyecharts.charts import Bar
from tools.path import cur_path

CURPATH = cur_path()


def myBar(name, xdata: list, ydata: dict):
    c = (
        Bar()
            .add_xaxis(
            xdata
        )
            .add_yaxis('2020', ydata['2020'])
            .add_yaxis('2021', ydata['2021'])
            .set_global_opts(
            xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-15)),
            title_opts=opts.TitleOpts(title=name.replace('.html', '')),
        )
            .render(os.path.join(CURPATH, "柱状图-%s.html" % name))
    )
